package org.sensation.server.operation.request;

import java.io.Serializable;
import java.util.Arrays;

public class Command implements Serializable{
	private static final long serialVersionUID = -2954176501909939119L;
	
	private int seqID;
	private int blockSize;
	private int blockNumber;
	private int destinationServerPort;
	private float fileSize;
	private String hostName;
	private String fileName;
	private String command;
	private int[] retrasmitNumbers;
	
	public Command() {
		super();
	}
	public Command(float fileSize, int blockSize, int blockNumber,
			String fileName) {
		super();
		this.fileSize = fileSize;
		this.blockSize = blockSize;
		this.blockNumber = blockNumber;
		this.fileName = fileName;
	}

	public int getSeqID() {
		return seqID;
	}
	public void setSeqID(int seqID) {
		this.seqID = seqID;
	}
	public float getFileSize() {
		return fileSize;
	}
	public void setFileSize(float fileSize) {
		this.fileSize = fileSize;
	}
	public int getBlockSize() {
		return blockSize;
	}
	public void setBlockSize(int blockSize) {
		this.blockSize = blockSize;
	}
	public int getBlockNumber() {
		return blockNumber;
	}
	public void setBlockNumber(int blockNumber) {
		this.blockNumber = blockNumber;
	}
	public String getHostName() {
		return hostName;
	}
	public void setHostName(String hostName) {
		this.hostName = hostName;
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public String getCommand() {
		return command;
	}
	public void setCommand(String command) {
		this.command = command;
	}
	public int[] getRetrasmitNumbers() {
		return retrasmitNumbers;
	}
	public void setRetrasmitNumbers(int[] retrasmitNumbers) {
		this.retrasmitNumbers = retrasmitNumbers;
	}
	public int getDestinationServerPort() {
		return destinationServerPort;
	}
	public void setDestinationServerPort(int destinationServerPort) {
		this.destinationServerPort = destinationServerPort;
	}
	
	@Override
	public String toString() {
		return "Command [seqID=" + seqID + ", blockSize=" + blockSize
				+ ", blockNumber=" + blockNumber + ", destinationServerPort="
				+ destinationServerPort + ", fileSize=" + fileSize
				+ ", hostName=" + hostName + ", fileName=" + fileName
				+ ", command=" + command + ", retrasmitNumbers="
				+ Arrays.toString(retrasmitNumbers) + "]";
	}
	
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + blockNumber;
		result = prime * result + blockSize;
		result = prime * result + ((command == null) ? 0 : command.hashCode());
		result = prime * result + destinationServerPort;
		result = prime * result
				+ ((fileName == null) ? 0 : fileName.hashCode());
		result = prime * result + Float.floatToIntBits(fileSize);
		result = prime * result
				+ ((hostName == null) ? 0 : hostName.hashCode());
		result = prime * result + Arrays.hashCode(retrasmitNumbers);
		result = prime * result + seqID;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Command other = (Command) obj;
		if (blockNumber != other.blockNumber)
			return false;
		if (blockSize != other.blockSize)
			return false;
		if (command == null) {
			if (other.command != null)
				return false;
		} else if (!command.equals(other.command))
			return false;
		if (destinationServerPort != other.destinationServerPort)
			return false;
		if (fileName == null) {
			if (other.fileName != null)
				return false;
		} else if (!fileName.equals(other.fileName))
			return false;
		if (Float.floatToIntBits(fileSize) != Float
				.floatToIntBits(other.fileSize))
			return false;
		if (hostName == null) {
			if (other.hostName != null)
				return false;
		} else if (!hostName.equals(other.hostName))
			return false;
		if (!Arrays.equals(retrasmitNumbers, other.retrasmitNumbers))
			return false;
		if (seqID != other.seqID)
			return false;
		return true;
	}
}
